package com.zzld.modules.sys.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zzld.core.service.BaseServiceImpl;
import com.zzld.modules.sys.entity.User;
import com.zzld.modules.sys.mapper.UserMapper;
import com.zzld.modules.sys.service.IUserService;

@Service("userService")
public class UserServiceImpl extends BaseServiceImpl<User> implements IUserService {

	@Autowired
	private UserMapper userMapper;
	
	public int save(User entity){
		return userMapper.insert(entity);
	}
	
	public int savesetive(User entity){
		return userMapper.insertSelective(entity);
	}
	
	public HashMap<String,Object> selectbyid(String id){
		return userMapper.selectbyid(id);
	}
	
	public int updateUser(User entity){
		if(entity.getLid()!=null){
			return (Integer)userMapper.updateById(entity);
		}
		return 0;
	}
	
	
	
	public List<User> selectAll(Map map){
		Map<String, Object> params = map;
		List<User> list = userMapper.selectjoinuser(params);
		return list;
	}
	
	public PageInfo selectjoinuser(Map map,int pageNum,int pageSize){
		Map<String, Object> params = map;
		// 以name字段升序排序
		PageHelper.startPage(pageNum,pageSize);
		List<User> list = userMapper.selectjoinuser(params);
		PageInfo page = new PageInfo(list);

		return  page;
	}
	
	public int delusercall(String key){
		return (Integer)userMapper.delusercall(key);
	}
}
